package com.yphone.net.bean;

import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.annotations.SerializedName;
import com.yphone.tools.NomalConstans;

public class BaseResultWrapper<T> implements Parcelable {
    public static final Creator<BaseResultWrapper> CREATOR = new Creator<BaseResultWrapper>() {
        public BaseResultWrapper createFromParcel(Parcel source) {
            return new BaseResultWrapper(source);
        }

        public BaseResultWrapper[] newArray(int size) {
            return new BaseResultWrapper[size];
        }
    };
    @SerializedName(alternate = {"Code"}, value = "code")
    public int code;
    @SerializedName(alternate = {"Data"}, value = "data")
    public T data;
    @SerializedName(alternate = {"Msg"}, value = "msg")
    public String msg;
    @SerializedName(alternate = {"Msgtype"}, value = "msgtype")
    public int msgtype;
    @SerializedName(alternate = {"R"}, value = "r")
    public int r;
    @SerializedName(alternate = {"Success"}, value = "success")
    public String success;

    public int describeContents() {
        return 0;
    }

    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.msg);
        dest.writeValue(this.code);
        dest.writeString(this.success);
        dest.writeInt(this.r);
        Bundle bundle = new Bundle();
        bundle.putParcelable(NomalConstans.DATA_KEY, (Parcelable) this.data);
        dest.writeBundle(bundle);
        dest.writeInt(this.msgtype);
    }

    public BaseResultWrapper() {
    }

    protected BaseResultWrapper(Parcel in) {
        this.msg = in.readString();
        this.code = (Integer) in.readValue(Integer.class.getClassLoader());
        this.success = in.readString();
        this.r = in.readInt();
        this.data = in.readBundle().getParcelable(NomalConstans.DATA_KEY);
        this.msgtype = in.readInt();
    }
}